package com.davidk.survey.client.root;

import com.davidk.survey.client.eventbus.MasterEventBus;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.mvp4g.client.annotation.Presenter;
import com.mvp4g.client.presenter.BasePresenter;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.layout.HLayout;

@Presenter(view = RootView.class)
public class RootPresenter extends BasePresenter<RootViewInterface, MasterEventBus> {

	public void onChangeBody(Canvas newPage) {
		view.setBody(newPage);
	}

	public void onChangeMenu(Canvas w) {
		view.setMenu(w);
	}

	public void onChangeTitle(Canvas w) {
		view.setTitle(w);
	}

	public void onDisplayMessage(String message) {
		view.showMessage(message);
	}

	public void onLoginSuccess(String userId) {
		HLayout title = new HLayout();
		title.addMember(new Label("Welcome, " + userId));
		eventBus.changeTitle(title);
	}
	

	public void onStart() {
	}

}
